package com.igoal.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.igoal.entity.DataStatus;
import com.igoal.entity.UserSchool;
import com.igoal.entity.UserSchoolPk;
import com.igoal.service.SaveResult;

@Repository("userSchoolDAO")
public class UserSchoolDAOImpl extends GenericDaoHibernate<UserSchool, UserSchoolPk> implements
		UserSchoolDAO {

	public UserSchoolDAOImpl() {
		super(UserSchool.class);
	}

	public List<UserSchool> getUserSchools(Long userId) {
		DetachedCriteria dc = DetachedCriteria.forClass(UserSchool.class);
		dc.add(Restrictions.eq("pk.user.id", userId));
		dc.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
		getByStatus(dc, DataStatus.USING);
		return findByCriteria(dc);
	}
}
